﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class MoveUI : MonoBehaviour, IPointerDownHandler,IPointerUpHandler
{
    bool canMove = false;
    RectTransform rectTransform;
    Canvas canvas;
    // Start is called before the first frame update
    void Start()
    {
        canvas = Manage_2.instance.canvas;
        rectTransform = this.GetComponent<RectTransform>();
    }

    // Update is called once per frame
    void Update()
    {
        if(canMove)
        {
            rectTransform.localPosition = GameFunction.MouseToUI(canvas);
        }
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        canMove = true;
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        canMove = false;
    }
}
